﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight;

namespace ProjectWizardManagementv1.WpfComponents.UserControls
{
    /// <summary>
    /// Interaction logic for DateBox.xaml
    /// </summary>
    public partial class DateBox : UserControl
    {
        private static readonly SolidColorBrush HighlightedColor = new SolidColorBrush(Color.FromArgb(255, 255, 253, 175));
        private SolidColorBrush _unhighlightedColor;
        public static ObservableCollection<DescriptionBox> CurrentEvents { get; set; }
        public ObservableCollection<DescriptionBox> EventsForThisDate { get; set; } 

        public ObservableCollection<DescriptionBox> Events
        {
            get
            {
                if(CurrentEvents == null)
                    CurrentEvents = new ObservableCollection<DescriptionBox>();
                return
                    new ObservableCollection<DescriptionBox>(
                    CurrentEvents.Where(
                        d => d.DayOfPosting.Month == AssignedDate.Month && d.DayOfPosting.Day == AssignedDate.Day).ToList());
            }
        }

        public SolidColorBrush UnhighlightedColor
        {
            set { _unhighlightedColor = value;
                this.Background = value;
            }
            get { return _unhighlightedColor; }
        }

        public string Day 
        {
            get { return this.DayNumber.Text; }
            set { this.DayNumber.Text = value; }
        }

        public DateTime AssignedDate { get; set; }

        //public List<CalendarDate> 

        public DateBox()
        {
            InitializeComponent();
            DataContext = this;
            this.Desc.ItemsSource = Events;
        }

        private void HighlightDate(object sender, MouseEventArgs e)
        {
            this.Background = HighlightedColor;
        }

        private void UnhighlightDate(object sender, MouseEventArgs e)
        {
            this.Background = UnhighlightedColor;
        }

        public void RaisePropertyChanged()
        {
            this.Desc.ItemsSource = Events;
        }
    }
}
